<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<div id="app"></div>
<div id="app1"></div>
</body>
<script src="js/vue.js"></script>
<script>

    /*
       初步使用 mixin
        Mixin 表示可以把部分参数抽取出来，然后通过 mixins 的属性添加进去
        可以把重复的选项抽取出来
    */
    const Mixin = {
        data() {
            return {
                msg: "Mixin 初体验",
                list: ['Tim', 'Jim', 'Tom', 'Ben', 'Jack', 'John', 'Nike'],
            }
        },
        methods: {
            hello() {
                console.log("hello");
            }
        },
    };

    /* 定义两个 app 实例 */
    const app = Vue.createApp({
        mixins:[Mixin], // 这里接受的是一个数组
        template: `
          <div>
          <h3>{{ msg }}</h3>
          <button @click="hello">点击</button>
          </div>
        `
    }).mount("#app");


    const app1 = Vue.createApp({
        mixins:[Mixin],
        template: `
          <div>
          <h3>{{ msg }}</h3>
          <button @click="hello">点击</button>
          </div>
        `
    });
    app1.mount("#app1");
</script>
</html>
